<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
 function toChinesNum(num){
     var changeNum = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九']; 
     var unit = ["", "十", "百", "千", "万"];
     num = parseInt(num);
     function getWan(temp){
        var strArr = temp.toString().split("").reverse();
        var newNum = "";
     　　for (var i = 0; i < strArr.length; i++) {
       　　newNum = (i == 0 && strArr[i] == 0 ? "" : (i > 0 && strArr[i] == 0 && strArr[i - 1] == 0 ? "" : changeNum[strArr[i]] + (strArr[i] == 0 ? unit[0] : unit[i]))) + newNum;
     　　}
      　 return newNum;
     }
    var overWan = Math.floor(num / 10000);
    var noWan = num % 10000;
    if (noWan.toString().length < 4) {
　　　　noWan = "0" + noWan;
　　}
    return overWan ? getWan(overWan) + "万" + getWan(noWan) : getWan(num);
 }

 console.log(toChinesNum(13123))

</script>
</html>